﻿using System;
using Microsoft.Office.Interop.Word;
using System.Windows.Media.Imaging;
using System.Drawing;
using System.IO;
using System.Reflection;

namespace CodeCounsel.Office.DatabindingToolkit
{
    public abstract class ControlType
    {
        public string Title { get; private set; }
        public string Description { get; protected set; }
        public BitmapImage Image { get; private set; }
        protected abstract string ImageResourceName { get; }

        public ControlType(string title, string description)
        {
            Title = title;
            Description = description;
            BitmapImage image = new BitmapImage();
            using (Stream stream =
                Assembly.GetExecutingAssembly().GetManifestResourceStream(
                    ImageResourceName))
            {
                image.BeginInit();
                image.StreamSource = stream;
                image.EndInit();
            }
            Image = image;
        }

        public override string ToString()
        {
            return Title;
        }
    }

    public abstract class ValueControl : ControlType
    {
        public abstract WdContentControlType WordType { get; }

        public ValueControl(string title, string description)
            : base(title, description)
        {
        }
    }

    class TextBoxControl
        : ValueControl
    {
        public override WdContentControlType WordType
        {
            get { return WdContentControlType.wdContentControlText; }
        }

        protected override string ImageResourceName
        {
            get { return "CodeCounsel.Office.DatabindingToolkit.Resources.TextBox.bmp"; }
        }

        public TextBoxControl()
            : base("Textbox", "A textbox control")
        {
        }
    }

    class ComboBoxControl
        : ValueControl
    {
        public override WdContentControlType WordType
        {
            get { return WdContentControlType.wdContentControlComboBox; }
        }

        protected override string ImageResourceName
        {
            get { return "CodeCounsel.Office.DatabindingToolkit.Resources.ComboBox.bmp"; }
        }

        public ComboBoxControl()
            : base("Combobox", "A dropdownlist which allows type-in")
        {
        }
    }

    class DropDownListControl
        : ValueControl
    {
        public override WdContentControlType WordType
        {
            get { return WdContentControlType.wdContentControlDropdownList; }
        }

        protected override string ImageResourceName
        {
            get { return "CodeCounsel.Office.DatabindingToolkit.Resources.ComboBox.bmp"; }
        }

        public DropDownListControl()
            : base("Dropdown list", "A dropdownlist which does not allow type-in")
        {
        }
    }

    class DatePickerControl
        : ValueControl
    {
        public override WdContentControlType WordType
        {
            get { return WdContentControlType.wdContentControlDate; }
        }

        protected override string ImageResourceName
        {
            get { return "CodeCounsel.Office.DatabindingToolkit.Resources.MonthCalendar.bmp"; }
        }

        public DatePickerControl()
            : base("Date picker", "A control to select dates")
        {
        }

    }
}
